﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization;

namespace DBMS.Models
{
    [Serializable()]
    public class Column : ISerializable
    {
        public int Index { get; set; }

        public bool PrimaryKey { get; set; }

        public bool SecondaryKey { get; set; }

        public string Name { get; set; }

        public string Type { get; set; }

        public IList<Value> Values { get; set; }

        public bool Deleted { get; set; }

        public Column() { }

        public Column(SerializationInfo info, StreamingContext ctxt)
        {
            this.Index = (int)info.GetValue("Index", typeof(int));
            this.PrimaryKey = (bool)info.GetValue("PrimaryKey", typeof(bool));
            this.SecondaryKey = (bool)info.GetValue("SecondaryKey", typeof(bool));
            this.Name = (string)info.GetValue("Name", typeof(string));
            this.Type = (string)info.GetValue("Type", typeof(string));
            this.Values = (IList<Value>)info.GetValue("Values", typeof(IList<Value>));
            this.Deleted = (bool)info.GetValue("Deleted", typeof(bool));
        }

        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            info.AddValue("Index", this.Index);
            info.AddValue("PrimaryKey", this.PrimaryKey);
            info.AddValue("SecondaryKey", this.SecondaryKey);
            info.AddValue("Name", this.Name);
            info.AddValue("Type", this.Type);
            info.AddValue("Values", this.Values);
            info.AddValue("Deleted", this.Deleted);
        }
    }
}
